<template>
	<view>
		<form>

			<view class="cu-form-group margin-top">
				<textarea  name="content"  maxlength="100" v-model="content" placeholder="内容"></textarea>
			</view>
			<!-- end -->
			

			

			
			<!-- 价钱 -->
				<view class="cu-form-group margin-top">
					<view class="title">报酬:</view>
					<input type="digit"  v-model="reward" placeholder="请输入报酬"  maxlength='7'></input>
			

			
				</view>
			<!-- end -->

			
			<!-- 确定发布 -->
			<view class="padding flex flex-direction">
			  <button class="cu-btn bg-green margin-tb-sm lg" @tap="postTask">发布任务</button>
			</view>
					<!-- end -->
		</form>
		
		
	</view>
</template>

<script>
	import store from '../../../globalStore/store.json'

	import getDate from '../../component/getNowFormatDate.js'

	export default {
		data() {
			return {

					content:'',
					reward:""

			}
		},
		onLoad() {

		},
		onShow() {
			uni.setNavigationBarTitle({
				title:"发布任务"
			})
		},
		methods: {
		

			
			postTask(){
				if(this.content.length==0){
					uni.showToast({
						title:"内容不能为空",
						duration:1000
					})
					return;
				}
				// else if(this.classify.length==0){
				// 	uni.showToast({
				// 		title:"请选择分类",
				// 		duration:1000
				// 	})
				// 	return;					
				// }
				uni.showLoading();
				
				setTimeout(function () {
					uni.hideLoading();
				}, 2000);
				let task={
					"task_id":Math.random().toString(36).substr(2),
					"user_name":store.user.user_name,
					"user_id":store.user.user_id,
					"user_icon":store.user.icon,
					"content":this.content,
					"time":getDate(),
					"reward":this.reward,
					"address":store.user.address,
					"phone":store.user.phone
				};
				uni.showLoading();
				console.log(task)

				uniCloud.callFunction({
					name:"publishTask",
					data:task,
					success(res){
						uni.hideLoading();
						console.log(res);
						uni.navigateBack();
					}
				})
				this.content="";
				this.gain="";

				
			},



		},

	}
</script>

<style>
.rule{
  display: flex;
  justify-content: space-between;
}
.margin-top-xl-170{
  margin-top: 170rpx;
}
</style>
